# Maintainer: kpcyrd <git@rxv.cc>
pkgname=wasm-bindgen
pkgver=0.2.92
pkgrel=0
pkgdesc="Interoperating JS and Rust code"
url="https://github.com/rustwasm/wasm-bindgen"
arch="all"
license="Apache-2.0"
depends="cargo nodejs rust-wasm"
makedepends="
	cargo-auditable
	"
source="https://github.com/rustwasm/wasm-bindgen/archive/refs/tags/$pkgver/wasm-bindgen-$pkgver.tar.gz
	Cargo-$pkgver.lock::https://gitlab.archlinux.org/archlinux/packaging/packages/wasm-bindgen/-/raw/$pkgver-1/Cargo.lock
	"
options="net !check" # most tests fail outside of x86_64

prepare() {
	default_prepare

	# https://github.com/rustwasm/wasm-bindgen/issues/1819
	mv "$srcdir/Cargo-$pkgver.lock" Cargo.lock

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cd crates/cli
	cargo auditable build --release --frozen
}

check() {
	cd crates/cli
	cargo test --frozen
}

package() {
	install -Dm755 -t "$pkgdir"/usr/bin \
		target/release/wasm-bindgen \
		target/release/wasm-bindgen-test-runner \
		target/release/wasm2es6js
}

sha512sums="
941d1f94bcbf53d7e47c899a50756c8fb72120c35ef965b13f7f86c14f423c7f2a7fbb75686d5f779b88d23fcc4891a54bc2b1a3971ab428f5932c7f3611e3fb  wasm-bindgen-0.2.92.tar.gz
4326ddff990993782fedd87e4b65a6e4d3ed531e1ede6587c68bd20e90f8f3d82640cf1aaf06674f7c70803e343cba4881a89185864bbf22dde1051e03795140  Cargo-0.2.92.lock
"
